using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace uk.org.aspellclark.todolistppc
{
	/// <summary>
	/// Summary description for frmTaskDetails.
	/// </summary>
	public class frmTaskDetails : System.Windows.Forms.Form, IDisposable
	{
        #region Member Variables
        private System.Drawing.Font m_Font;
        private System.Windows.Forms.TextBox m_tbxTitle;
        private System.Windows.Forms.Label m_lblTitle;
        private System.Windows.Forms.Label m_lblComments;
        private System.Windows.Forms.TextBox m_tbxComments;
        private System.Windows.Forms.Button m_btnCancel;
        private Microsoft.WindowsCE.Forms.InputPanel m_inputPanel;
        private System.Windows.Forms.MainMenu m_mnuMain;
        private DialogResult m_drResult = DialogResult.OK;
        private CTask m_taskDetails = null;
		#endregion
        
        #region Properties

        /// <summary>
        ///
        /// </summary>
        public System.Drawing.Font ctrlFont
        {
            get { return m_Font;  }
            set { m_Font = value;
            	m_tbxTitle.Font = m_Font;
            	m_lblTitle.Font = m_Font;
            	m_lblComments.Font = m_Font;
            	m_tbxComments.Font = m_Font;
            	m_lblComments.Font = m_Font;
            	m_tbxComments.Font = m_Font; }
        }
        /// <summary>
        /// returns the result of the dialog (OK or Cancel) signifying which button was pressed to close the dialog
        /// </summary>
        public DialogResult GetDialogResult
        {
            get { return m_drResult; }
            set { m_drResult = value; }
        }
        /// <summary>
        /// returns the result of the dialog (OK or Cancel) signifying which button was pressed to close the dialog
        /// </summary>
        public CTask TaskDetails
        {
            get { return m_taskDetails; }
            set { m_taskDetails = value; }
        }

        #endregion


        #region IDisposable Members

        void System.IDisposable.Dispose()
        {
            Dispose();
        }

        #endregion



        /// <summary>
        /// the constructor
        /// </summary>
		public frmTaskDetails(CTask pTaskDetails)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            m_taskDetails = pTaskDetails;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.m_inputPanel = new Microsoft.WindowsCE.Forms.InputPanel();
            this.m_mnuMain = new System.Windows.Forms.MainMenu();
            this.m_btnCancel = new System.Windows.Forms.Button();
            this.m_tbxTitle = new System.Windows.Forms.TextBox();
            this.m_lblTitle = new System.Windows.Forms.Label();
            this.m_lblComments = new System.Windows.Forms.Label();
            this.m_tbxComments = new System.Windows.Forms.TextBox();
            // 
            // m_btnCancel
            // 
            this.m_btnCancel.Location = new System.Drawing.Point(176, 224);
            this.m_btnCancel.Size = new System.Drawing.Size(50, 20);
            this.m_btnCancel.Text = "Cancel";
            this.m_btnCancel.Click += new System.EventHandler(this.m_btnCancel_Click);
            // 
            // m_tbxTitle
            // 
            this.m_tbxTitle.Location = new System.Drawing.Point(48, 8);
            this.m_tbxTitle.Size = new System.Drawing.Size(176, 20);
            this.m_tbxTitle.Text = "";
            this.m_tbxTitle.TextChanged += new System.EventHandler(this.m_tbxTitle_TextChanged);
            // 
            // m_lblTitle
            // 
            this.m_lblTitle.Location = new System.Drawing.Point(0, 8);
            this.m_lblTitle.Size = new System.Drawing.Size(48, 16);
            this.m_lblTitle.Text = "Title:";
            // 
            // m_lblComments
            // 
            this.m_lblComments.Location = new System.Drawing.Point(0, 32);
            this.m_lblComments.Size = new System.Drawing.Size(48, 16);
            this.m_lblComments.Text = "Cmnts:";
            // 
            // m_tbxComments
            // 
            this.m_tbxComments.Location = new System.Drawing.Point(48, 32);
            this.m_tbxComments.Multiline = true;
            this.m_tbxComments.Size = new System.Drawing.Size(176, 104);
            this.m_tbxComments.Text = "";
            this.m_tbxComments.TextChanged += new System.EventHandler(this.m_tbxComments_TextChanged);
            // 
            // frmTaskDetails
            // 
            this.ClientSize = new System.Drawing.Size(226, 248);
            this.Controls.Add(this.m_lblComments);
            this.Controls.Add(this.m_tbxComments);
            this.Controls.Add(this.m_lblTitle);
            this.Controls.Add(this.m_tbxTitle);
            this.Controls.Add(this.m_btnCancel);
            this.Menu = this.m_mnuMain;
            this.Text = "frmTaskDetails";
            this.Resize += new System.EventHandler(this.frmTaskDetails_Resize);
            this.Load += new System.EventHandler(this.frmTaskDetails_Load);

        }
		#endregion

        private void m_btnCancel_Click(object sender, System.EventArgs e)
        {
            m_inputPanel.Enabled = false;
            m_drResult = DialogResult.Cancel;
            this.Close();
        }

        private void m_cmbType_GotFocus(object sender, System.EventArgs e)
        {
            m_inputPanel.Enabled = true;
        }

        private void m_inputPanel_EnabledChanged(object sender, System.EventArgs e)
        {
            if (m_inputPanel.Enabled == true)
            {
                this.Height = m_inputPanel.VisibleDesktop.Height;
            }
            else
            {
                this.Height = this.Height - 20;
            }
        }

        private void frmTaskDetails_Resize(object sender, System.EventArgs e)
        {
            this.Width = Screen.PrimaryScreen.Bounds.Width;
            this.Height = Screen.PrimaryScreen.Bounds.Height;
            if (Screen.PrimaryScreen.Bounds.Width > Screen.PrimaryScreen.Bounds.Height)
            {
                //Landscape();
            }
            else
            {
                //Portrait();
            }
        }

        private void frmTaskDetails_Load(object sender, System.EventArgs e)
        {
            DisplayTaskDetails();
        }

        private void DisplayTaskDetails()
        {
            m_tbxTitle.Text = m_taskDetails.Title;
            m_tbxComments.Text = m_taskDetails.Notes;
        }

        private void m_tbxTitle_TextChanged(object sender, System.EventArgs e)
        {
            m_taskDetails.Title = m_tbxTitle.Text;
        }

        private void m_tbxComments_TextChanged(object sender, System.EventArgs e)
        {
            m_taskDetails.Notes = m_tbxComments.Text;
        }

	}
}
